package com.smallrig.mall.template.huawei;

import java.util.Stack;

public class 单调栈 {

    static int[] nums = new int[]{1,2,-1,1,5};
    public static void main(String[] args) {
        int[] left = new int[nums.length];
        int[] right = new int[nums.length];

        Stack<Integer> stack = new Stack<>();
        for(int i=0;i<nums.length;i++){

            //栈非空 && 栈顶大于当前则一直弹栈
            while(!stack.isEmpty()&&nums[stack.peek()]<nums[i]){
                right[stack.pop()] = nums[i];
            }
            if(!stack.isEmpty()){
                left[i] = nums[stack.peek()];
            }
            //栈顶元素<=当前
            stack.push(i);
        }

        System.out.println(1);

    }

}
